var /**
	 * 仿真流程管理
	 */
TeachFlow = cc.Class.extend({
	step:0,
	flow:null,
	main:null,
	over_flag: false,
	curSprite:null,
	ctor: function(){
		this.init();
	},
	setMain:function(main){
		this.main=main;
	},
	init: function(){
		for(var i in teach_flow){
			teach_flow[i].finish = false;
			teach_flow[i].cur = false;
			if(teach_flow[i].action == null){
				teach_flow[i].action = ACTION_NONE;
			}
		}
	},
	start:/**
			 * 开始流程
			 */
	function(){
		this.over_flag = false;
		this.step = 0;
		
		/* 新标准，开始的时候，执行下一步 */
		this.next();
	},
	over:/**
			 * 流程结束，计算分数，跳转到结束场景，
			 */
	function(){
		this.over_flag = true;
		this.flow = over;
		gg.lastStep = this.step;
		this.main.over();
	},
	checkTag:/**
				 * 检查是否当前步骤
				 * 
				 * @deprecated 使用新Angel类，不再判断是否当前步骤
				 * @param tag
				 * @returns {Boolean}
				 */
	function(tag){
		var cur_flow = teach_flow[this.step - 1];
		if(cur_flow.tag == tag){
			return true;
		} else {
			return false;
		}
	},
	prev:/**
			 * 回退一定步数
			 * 
			 * @deprecated 需结合具体实现，，暂时不再启动
			 * @param count
			 *            步数
			 */
	function(count){
		if(this.curSprite!=null){
			this.curSprite = null;
		}
		if(this.flow!=null){
			this.flow.cur = false;
		}
		this.step = this.step - count;
		this.flow = teach_flow[this.step - 1];
		this.refresh();
		gg.score -= 11;
	},
	next:/**
			 * 执行下一步操作， 定位当前任务
			 */
	function(){
		if(this.over_flag){
			return;
		}
		if(this.curSprite!=null){
			this.curSprite.setEnable(false)
			this.curSprite = null;
		}
		if(this.flow!=null){
			this.flow.cur = false;
			// 标记任务已完成
			this.flow.finish = true;
		}
		this.flow = teach_flow[this.step++];
		if(this.flow.finish){
			// 如果任务已完成，跳过当前步骤
			this.next();
		}
		this.refresh();
	},
	refresh:/**
			 * 刷新当前任务状态，设置闪现，点击等状态
			 */
	function(){
		// 刷新提示
		this.flow.cur = true;
		if(this.flow.tip != null){
			ll.tip.tip.doTip(this.flow.tip);
		}
		if(this.flow.flash != null){
			ll.tip.flash.doFlash(this.flow.flash);
		}
		if(this.step > teach_flow.length - 1){
			this.over();
		}
		this.initCurSprite();
		if(this.curSprite!=null){
			this.location();
			this.curSprite.setEnable(true);
		}
	},
//	location:/**
//	 * 定位箭头
//	 */
//		function(){
//			ll.tip.arr.pos(this.curSprite);
//	},
	location:/**
	 * 定位箭头
	 */
		function(){
		var tag = gg.flow.flow.tag;
		if(tag instanceof Array){
			if(TAG_LIB_MIN < tag[1]){
				if(ll.run.lib.isOpen()){
					ll.tip.arr.pos(this.curSprite);
				}else{
					//ll.tip.arr.setPosition(gg.width-45,455);

					ll.tip.arr.pos(ll.tool.getChildByTag(TAG_BUTTON_LIB),gg.flow.flow.X,gg.flow.flow.Y);
				}
			}else{
				ll.tip.arr.pos(this.curSprite,gg.flow.flow.X,gg.flow.flow.Y);
			}
		}
		else {
			ll.tip.arr.pos(this.curSprite,gg.flow.flow.X,gg.flow.flow.Y);
		}		
	},
	getStep:/**
			 * 获取当前步数
			 * 
			 * @returns {Number}
			 */
	function(){
		return this.step;
	},
	initCurSprite:/**
					 * 遍历获取当前任务的操作对象
					 */
	function(){
		var tag = this.flow.tag;
		if(tag == null || tag == undefined){
			return;
		}
		var root = ll.run;
		var sprite = null;
		if(tag == TAG_BUTTON_LIB){
			sprite = ll.tool.getChildByTag(tag);
		} else if(tag instanceof Array){
			// 数组
			for (var i in tag) {
				root = root.getChildByTag(tag[i]);
			}
			sprite = root;
		} else {
			// 单个tag
			var sprite = root.getChildByTag(tag);
		}
		if(sprite != null){
			this.curSprite = sprite;
			return;
		}
	}
});
// 任务流
teach_flow = [
// 取5g粗食盐
	{tip:"1.打开物品库",tag:TAG_BUTTON_LIB},
	{tip:"取出记录本",tag:[TAG_LIB,TAG_LIB_BOOK]},
	{tip:"打开记录本,在记录本上填写使用记录信息",tag:[TAG_BOOK_ALL,TAG_BOOK]},
	{tip:"来到电子天平背面",tag:[TAG_BALANCE_ALL,TAG_BALANCE],action:ACTION_DO1},
	{tip:"查看气泡是否在圆圈中心位置",tag:[TAG_BALANCE_ALL,TAG_BUBBLE]},
	{tip:"调平,顺时针拨动右边旋钮",tag:[TAG_BALANCE_ALL,TAG_KNOB1]},
	{tip:"调平,顺时针拨动左边旋钮",tag:[TAG_BALANCE_ALL,TAG_KNOB]},
	{tip:"回到电子天平正面",tag:[TAG_BALANCE_ALL,TAG_BALANCE],action:ACTION_DO2},
	{tip:"将插座插在电源上",tag:[TAG_BALANCE_ALL,TAG_POWERLINE]},
	{tip:"按ON/OFF开机,预热30分钟",tag:[TAG_BALANCE_ALL,TAG_BOOT]},
	{tip:"取出刷子",tag:[TAG_LIB,TAG_LIB_BRUSH]},
	{tip:"打开天平门",tag:[TAG_BALANCE_ALL,TAG_DOOR],action:ACTION_DO1},
	{tip:"用刷子清扫秤盘",tag:[TAG_BRUSH_ALL,TAG_BRUSH],X:0.3,Y:0.5},
	{tip:"关闭天平门",tag:[TAG_BALANCE_ALL,TAG_DOOR],action:ACTION_DO2},
	{tip:"按Tare键,将电子天平调零处理",tag:[TAG_BALANCE_ALL,TAG_TARE]},
	{tip:"打开天平门",tag:[TAG_BALANCE_ALL,TAG_DOOR],action:ACTION_DO3},
	{tip:"取出称量瓶",tag:[TAG_LIB,TAG_LIB_WEIGHING]},
//	{tip:"将装有基准碳酸钠的称量瓶放在秤盘上,待读数稳定记录数据",tag:[TAG_WEIGHING_ALL,TAG_WEIGHING],action:ACTION_DO1},
	{tip:"关闭天平门",tag:[TAG_BALANCE_ALL,TAG_DOOR],action:ACTION_DO4},
	{tip:"取出烧杯",tag:[TAG_LIB,TAG_LIB_BEAKER]},
	{tip:"打开天平门",tag:[TAG_BALANCE_ALL,TAG_DOOR],action:ACTION_DO5},
	{tip:"取出称量瓶",tag:[TAG_WEIGHING_ALL,TAG_WEIGHING],action:ACTION_DO2},
	{tip:"打开称量瓶瓶盖",tag:[TAG_WEIGHING_ALL,TAG_WEIGHING,TAG_CUP]},
	{tip:"将称量瓶内部分粉末敲入烧杯中",tag:[TAG_WEIGHING_ALL,TAG_WEIGHING],action:ACTION_DO3},
	{tip:"将称量瓶放在秤盘上",tag:[TAG_WEIGHING_ALL,TAG_WEIGHING],action:ACTION_DO4},
	{tip:"关闭天平门,待读数稳定后,将数值记录在记录本上,并判断差值是否在10.4-10.8之间",tag:[TAG_BALANCE_ALL,TAG_DOOR],action:ACTION_DO6},
	{tip:"打开天平门",tag:[TAG_BALANCE_ALL,TAG_DOOR],action:ACTION_DO7},
	{tip:"取出称量瓶",tag:[TAG_WEIGHING_ALL,TAG_WEIGHING],action:ACTION_DO5},
	{tip:"关闭天平门",tag:[TAG_BALANCE_ALL,TAG_DOOR],action:ACTION_DO8},
	{tip:"关闭天平",tag:[TAG_BALANCE_ALL,TAG_BOOT],action:ACTION_DO1},
	{tip:"取出蒸馏水瓶",tag:[TAG_LIB,TAG_LIB_KETTLE]},
	{tip:"将少量蒸馏水倒入烧杯中",tag:[TAG_KETTLE_ALL,TAG_KETTLE]},
	{tip:"取出玻璃棒",tag:[TAG_LIB,TAG_LIB_GLASS],action:ACTION_DO1},
	{tip:"用玻璃棒搅拌使粉末充分溶解",tag:[TAG_GLASS_ALL,TAG_GLASS],X:0.35,Y:0.5},
	{tip:"取出容量瓶",tag:[TAG_LIB,TAG_LIB_FLASK]},
	{tip:"打开容量瓶",tag:[TAG_FLASK_ALL,TAG_FLASK,TAG_FLASK_LID],action:ACTION_DO1},
	{tip:"取出玻璃棒",tag:[TAG_LIB,TAG_LIB_GLASS],action:ACTION_DO2},
	{tip:"将烧杯中溶解后的溶液转移入容量瓶中",tag:[TAG_BEAKER_ALL,TAG_BEAKER]},
	{tip:"将少量蒸馏水倒入烧杯中,润洗烧杯壁",tag:[TAG_KETTLE_ALL,TAG_KETTLE],action:ACTION_DO1},
	{tip:"将润洗后溶液转移入容量瓶中,待容量瓶中溶液水位线离1000ml差1-2cm",tag:[TAG_BEAKER_ALL,TAG_BEAKER],action:ACTION_DO1},
	{tip:"将蒸馏水倒入烧杯中",tag:[TAG_KETTLE_ALL,TAG_KETTLE],action:ACTION_DO2},
	{tip:"取出胶头滴管",tag:[TAG_LIB,TAG_LIB_DROP]},
	{tip:"用胶头滴管吸取烧杯中蒸馏水,将蒸馏水滴入容量瓶中直至水位线达到1000ml位置",tag:[TAG_DROP_ALL,TAG_DROP]},
	{tip:"盖上容量瓶盖子",tag:[TAG_FLASK_ALL,TAG_FLASK,TAG_FLASK_LID],action:ACTION_DO2},
	{tip:"恭喜过关",over:true}
];
over = {tip:"恭喜过关"};



